package com.struts.deal.homepage;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ibatis.po.system.TCiyt;
import com.ibatis.po.user.TStation;
import com.ibatis.po.user.TVocation;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.lg.system.CDBManager;
import com.lg.system.CSqlMap;
import com.struts.web.homepage.HomePageForm;

public class Deal {

	public static void  doDefaultSearchVocation(
			HttpServletRequest request,
            HttpServletResponse response,
            HomePageForm aWebForm){
		List cityList=null;
		List stationList = null;
		List vocationList = null;
    	TCiyt cityPo = new TCiyt();
    	TStation stationPo= new TStation();
    	TVocation vocationPo = new TVocation();
    	SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
    	try{
    	String str="";
    	String str2="";
    	String str3="";
    	String sKey="";
        String sValue="";
        
        

        //岗位列表
		str += "var station=new Array('','－－请选择岗位－－'";
		stationList = sqlmap.queryForList("T_STATION.selectAll");
		for(int i=0;i<stationList.size();i++){
			stationPo = (TStation)stationList.get(i);
        	str += ",'"+stationPo.getId()+"',";
        	str += "'" + stationPo.getSortName() + "'\n";
        }
        str += ");\n";
        System.out.println("****************"+str);
        //行业列表
        vocationList = sqlmap.queryForList("T_VOCATION.selectAll");
        str2 += "var vocation=new Array('','－－请选择行业－－'";
        for(int i=0;i<vocationList.size();i++){
        	vocationPo = (TVocation)vocationList.get(i);
        	str2 += ",'"+vocationPo.getId()+"',";
        	str2 += "'" + vocationPo.getVocationName() + "'\n";
        }
        str2 += ");\n";
        
        //地区列表
        str3 += "var workplace=new Array('','工作地点'";
        cityList = sqlmap.queryForList("T_CIYT.selectAllCity");
        for(int i=0;i<cityList.size();i++){
        	cityPo = (TCiyt)cityList.get(i);
        	sKey = cityPo.getId();
        	sValue = cityPo.getCityName();
            if((Integer.parseInt(sKey)%100)==0){
            str3 += ",'" + sKey + "',"; 
            str3 += "'" + sValue + "'\n"; 
            }else{
            	 str3 += ",'" + sKey + "',"; 
                 str3 += "'&nbsp;&nbsp;&nbsp;&nbsp;" + sValue + "'\n";
            }
        }
        str3 += ");\n";
        
        aWebForm.setPrintStaSql(str);
        aWebForm.setPrintVacaSql(str2);
        aWebForm.setPrintWorkplaceSql(str3);
    	}catch(Exception e){
    		e.printStackTrace();
    		}
    	
	}
}
